<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>编辑部落成员</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  <script src="/scripts/jquery.min.js"></script>
  <script src="/scripts/boot.js" type="text/javascript"></script>
  <script src="/scripts/miniui/miniui.js"></script>

  <style type="text/css">
    html, body {
      font-size: 12px;
      padding: 0;
      margin: 0;
      border: 0;
      height: 100%;
      overflow: hidden;
    }
  </style>
</head>
<body>

<!--<form id="form1" name="form1" method="post" action='/tribeRoute/addTribeMember' enctype="text/plain" >-->
<form id="form1" name="form1">
  <input name="userId" class="mini-hidden" />
  <input name="oldUserType" class="mini-hidden" />
  <input name="tirbeMemberId" class="mini-hidden" />
  <div style="padding-left:11px;padding-bottom:5px; margin-top: 20px">
    <table style="table-layout:fixed; margin: 0 auto;text-align: center;">
      <tr>
        <td style="width:60px;">部落名称：</td>
        <td >
          <input name="tribeName" class="mini-textbox" style="width:200px;margin-right: 20px;" type="text" allowInput="false"/>
        </td>
        <td style="width:60px;">部落ID：</td>
        <td >
          <input name="tribeOId" class="mini-textbox" style="width:200px;" type="text"  allowInput="false"/>
        </td>
      </tr>
      <tr>
        <td style="width:60px;">成员名称：</td>
        <td >
          <input name="memberName" class="mini-textbox" style="width:200px;margin-right: 20px;" type="text"  allowInput="false"/>
        </td>
        <td style="width:60px;">成员类型：</td>
        <td >
          <input id="userType" name="userType" class="mini-combobox" style="width:200px;" type="text" required="true" data="memberType"/>
        </td>
      </tr>

    </table>
  </div>
  <div style="text-align:center;padding:10px; margin-top: 10px">
    <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
    <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
  </div>
</form>
<script type="text/javascript">
  var memberType = [{ id: -1, text: '非成员' },{ id: 0, text: '黑名单' },{ id: 2, text: '管理员'},{ id: 3, text: '成员'}];
  mini.parse();
  var form = new mini.Form("form1");
  function SaveData() {
    var form = new mini.Form("#form1");
    form.validate();
    var data = form.getData();
//    console.log(data);
    if (data.userType == data.oldUserType) {
      alert('数据无变化！');
      return;
    }
    $.ajax({
      url: "/tribeRoute/tribeMemberEditHandle",
      type: 'post',
      data: data,
      cache: false,
      success: function (res) {
        var resultData = JSON.parse(res);
        alert(resultData);
        CloseWindow("ok");
      },
      error: function (error) {
        console.log(error)
      }
    });
  }
  ////////////////////
  //标准方法接口定义
  function SetData(data) {
//    console.log(data);
    if(data) {
      var tribeData = mini.clone(data);
      mini.getbyName("userId").setValue(tribeData.userId);
      mini.getbyName("tribeName").setValue(tribeData.tribeName);
      mini.getbyName("tribeOId").setValue(tribeData.tribeOId);
      mini.getbyName("memberName").setValue(tribeData.memberName);
      mini.getbyName("userType").setValue(tribeData.userType);
      mini.getbyName("oldUserType").setValue(tribeData.userType);
      mini.getbyName("tirbeMemberId").setValue(tribeData.tirbeMemberId);
    }
  };

  function GetData() {
    var o = form.getData();
    return o;
  }

  function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
      if (confirm("数据被修改了，是否先保存？")) {
        return false;
      }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
  }

  function onOk(e) {
    SaveData();
  }

  function onCancel(e) {
    CloseWindow("cancel");
  }

</script>
</body>
</html>
